;Make a DM, with 5x5 actuators but where the corner numbers aren't
;input. Numbering starts from top left. This makes a smooth DM...
;ic_jdm, make_dm5_noc([replicate(0,5),1,replicate(0,15)],psize,lenslet_pitch, m_pix), /noc
function make_dm5_noc, posns, psize,lenslet_pitch, m_pix

new_posns = fltarr(25)
new_posns[1:3]=posns[0:2]
new_posns[5:19]=posns[3:17]
new_posns[21:23]=posns[18:20]
new_posns[0]=new_posns[1]+new_posns[5]-new_posns[6]
new_posns[20]=new_posns[21]+new_posns[15]-new_posns[16]
new_posns[4]=new_posns[3]+new_posns[9]-new_posns[8]
new_posns[24]=new_posns[23]+new_posns[19]-new_posns[18]
a = fltarr(5,5)
a[*]=new_posns
b = fltarr(7,7)
b[1:5,1:5]=a
b[0,1:5]=a[0,*]
b[6,1:5]=a[4,*]
b[1:5,0]=a[*,0]
b[1:5,6]=a[*,4]
b -= mean(b) ;;Remove piston
mult = round(lenslet_pitch/m_pix)
c=regrid_fft(b,7*mult,7*mult)
dm = fltarr(psize,psize)
dm[psize/2-3*mult:psize/2+3*mult,psize/2-3*mult:psize/2+3*mult] = c[0:6*mult,0:6*mult]
;t = psize/2 + lenslet_pitch/m_pix*(indgen(5)-2)
;x = reform(rebin(t,5,5),25,1)
;y = rebin(t,25, /samp)
;triangulate, x, y, triangles
;dm = trigrid(x,y, new_posns, triangles, [1,1], [0,0,psize-1,psize-1])
return, dm
end
